package cn.lcc.controller;

import cn.lcc.domain.User;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.concurrent.ThreadLocalRandom;

@RestController
@RequestMapping("/user")
@RefreshScope//动态刷新
public class UserController {

    @Value("${server.port}")
    private Integer port;

    @Value("${hm.test}")
    private String hmTest;

    @GetMapping("/{id}")
    public User get(@PathVariable("id") Long id){
       // System.out.println(1/0);
        /*int i = ThreadLocalRandom.current().nextInt(2);//[0,2)  0 1
        System.out.println(1/i);*/
        return new User(id,"悠亚"+port+":"+hmTest);
    }
}
